#include "headers.h"

int Set::SetCount=0;

Set::Set(const Set* genSetParam, QString genSymbolParam)
{
    number=SetCount++;
    genSet.insert(genSetParam);
    genSymbol=genSymbolParam;
}

bool Set::addRWI(const Rule* ruleParam, int indexParam)
{
    RWI rwi(ruleParam, indexParam);
    if(!rules.contains(rwi))
    {
        rules.append(rwi);
        return true;
    }
    return false;
}

QStringList Set::toStringList()
{
    QStringList resultList;
    foreach(RWI rwi, rules)
    {
        resultList.append(rwi.toString());
    }
    return resultList;
}

bool Set::isEmpty()
{
    return rules.isEmpty();
}

bool Set::operator ==(Set setParam)
{
    if(genSymbol!=setParam.genSymbol)
        return false;
    foreach(RWI rule, setParam.rules)
        if(!rules.contains(rule))
            return false;
    foreach(RWI rule, rules)
        if(!setParam.rules.contains(rule))
            return false;
    return true;
}
